<template lang="jade">
h-loader-full(url='loader',:setdata='false')
  button(type='button', @click='ild_slide', style="display:none") 导入
  div(class='ild', 'style="display:none"')
    input(type='file', name='excelFile', @change='changefile')
    button(type='button' @click='upload_excel') 提交
    a(href="/1.xlsx") 下载导入模板
  div
  .box
    //查询
    m-title(icon='add',name='审核通过公司列表')
      input.input(v-model='p.cname', type='text',placeholder='公司名称')
      input.input(v-model='p.address', type='text',placeholder='公司地址')
      button(@click='goFilter(p)') 过滤
    //人员信息
    table.list
      ml-header(data='序号,公司名称,公司地址,联系人姓名,联系人电话,公司logo,公司状态,操作')
      tr(v-for='(n,i) in list')
        td {{n.id}}
        td {{n.cname}}
        td {{n.address}}
        td {{n.contact_name}}
        td {{n.contact_mobile}}
        td 
          <img :src="'http://image.mod.hesq.com.cn/xiongan/logo/'+n.logo" style='width:80px;'>
        td {{examine[n.status]}}
        td
          a(:href="'./company_datail.html?id=' + n.id") 详情
          <a :href="'./job_add.html?id=' + n.id">添加岗位</a>
          a(href='javascript:void(0)',class='update',:data-index='i') 更新
          a(:href="'./company_change.html?id=' + n.id") 修改
          a(@click='deletecom(n.id)' href='') 删除
    .command
      .page
        button(v-show='page>1', @click="pagego('last')") 上一页
        button {{page}}
        button(@click="pagego('next')") 下一页
</template>

----------------------------------------------------------------------------------------
<script>
import { MessageBox } from 'mint-ui'
export default {
	data () {
		return {
			loader:{
        list:'get_company/list'
        },
      url:{
				update:'hot/compant',
			},
      list:[],
      p:{
        cname:'',
        address:''
      },
      page:1,
      examine:['待审核','审核通过','审核未通过'],
      file:'',
		}
	},
  mounted () {
  },
	methods: {
		loadAfter(data){
      this.list=data.list[0]
		},
    //过滤
    goFilter (p) {
			this.$ajax.get('get_company/list?cname='+ this.p.cname + '&address=' + this.p.address, (res) => {
				this.list = res.data[0]
        this.page = 1
			}, (res) => {
				this.error(res.message)
			})
		},
    // 分页
    pagego (type) {
      this.page = type == 'last' ? this.page - 1 : this.page + 1
      this.$ajax.get('get_company/list?cname=' + this.p.cname + '&address=' + this.p.address +  '&page=' + this.page, (res) => {
        this.list = res.data[0]
      }, (res) => {
        this.error(res.message)
      })
    },
    deletecom (id){
      if(confirm('确定要删除？')){
        this.$ajax.get('get/delete/company/'+id);
      }
    },
    changefile(data){
      this.file = data.target.files[0];
      console.log(this.file);
    },
    upload_excel(){
      let formdata = new FormData()
      formdata.append('exfile',this.file)
      this.$ajax.post('post/excelimport',formdata,(res)=>{
        this.$msg.success('导入成功')
        setTimeout(function(){
          window.location.href = window.location.href;
        },1000);
      },(res)=>{
        this.$msg.error('导入失败')
      })
    },
    ild_slide(){
      $('.ild').slideToggle();
    }
	}
}
</script>
----------------------------------------------------------------------------------------
<style lang="less" scoped>
@import "../../../plugin/style/mixin";
.page{ float:right; }
  .page a{background: #4db3ff; color: #fff; padding:3px 10px; border-radius:4px; cursor:pointer;}
  .page b{margin:0 10px;}
</style>